<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="组织层级" prop="fdOrganizationLevel">
        <el-input
          v-model="queryParams.fdOrganizationLevel"
          placeholder="请输入组织层级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车牌号码" prop="fdPlateNum">
        <el-input
          v-model="queryParams.fdPlateNum"
          placeholder="请输入车牌号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ys:transportCostAccounting:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ys:transportCostAccounting:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ys:transportCostAccounting:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ys:transportCostAccounting:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="transportCostAccountingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键编码" align="center" prop="id" />
      <el-table-column label="序号" align="center" prop="fdSerialNum" />
      <el-table-column label="组织名称" align="center" prop="fdOrganizationName" />
      <el-table-column label="组织代码" align="center" prop="fdOrganizationCode" />
      <el-table-column label="组织分类" align="center" prop="fdOrganizationCategory" />
      <el-table-column label="组织层级" align="center" prop="fdOrganizationLevel" />
      <el-table-column label="车牌号码" align="center" prop="fdPlateNum" />
      <el-table-column label="车辆条形码" align="center" prop="fdVehicleBarcode" />
      <el-table-column label="预计车辆总运量" align="center" prop="fdEstimatedTotalVehicleVolume" />
      <el-table-column label="预计年总运量" align="center" prop="fdEstimatedAnnualTotalVehicleVolume" />
      <el-table-column label="车款总额" align="center" prop="fdTotalVehicleAmount" />
      <el-table-column label="折旧年限" align="center" prop="fdDepreciationYears" />
      <el-table-column label="折旧月数" align="center" prop="fdDepreciationMonths" />
      <el-table-column label="折旧残值" align="center" prop="fdResidualValueOfDepreciation" />
      <el-table-column label="公里折旧费小计" align="center" prop="fdSubtotalOfDepreciationPerKilometer" />
      <el-table-column label="贷款总额" align="center" prop="fdTotalLoanAmount" />
      <el-table-column label="月贷" align="center" prop="fdMonthlyLoanPayment" />
      <el-table-column label="利息总额" align="center" prop="fdTotalInterestPaid" />
      <el-table-column label="公里贷利费小计" align="center" prop="fdSubtotalOfLoanInterestAndFeesPerKilometer" />
      <el-table-column label="保养费" align="center" prop="fdMaintenanceCost" />
      <el-table-column label="维修费" align="center" prop="fdRepairCost" />
      <el-table-column label="货运信息费" align="center" prop="fdCargoInformationFee" />
      <el-table-column label="车船使用费" align="center" prop="fdVehicleAndVesselUseFee" />
      <el-table-column label="交强险" align="center" prop="fdCompulsoryInsurance" />
      <el-table-column label="商业险" align="center" prop="fdCommercialInsurance" />
      <el-table-column label="年检费" align="center" prop="fdAnnualInspectionFee" />
      <el-table-column label="营运费" align="center" prop="fdOperationalExpenses" />
      <el-table-column label="燃料类别" align="center" prop="fdFuelType" />
      <el-table-column label="耗费量" align="center" prop="fdFuelConsumption" />
      <el-table-column label="单价" align="center" prop="fdUnitPrice" />
      <el-table-column label="燃料费用" align="center" prop="fdFuelCost" />
      <el-table-column label="后处理费用" align="center" prop="fdPostProcessingCost" />
      <el-table-column label="过桥费" align="center" prop="fdBridgeToll" />
      <el-table-column label="过路费类别" align="center" prop="fdRoadTollCategory">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.toll_category" :value="scope.row.fdRoadTollCategory"/>
        </template>
      </el-table-column>
      <el-table-column label="过路费" align="center" prop="fdRoadToll" />
      <el-table-column label="换轮胎里程" align="center" prop="fdMileageForTyreChange" />
      <el-table-column label="轮胎单价" align="center" prop="fdUnitPriceOfTyre" />
      <el-table-column label="轮胎个数" align="center" prop="fdNumberOfTyres" />
      <el-table-column label="轮胎单耗" align="center" prop="fdTireUnitConsumption" />
      <el-table-column label="司机薪资" align="center" prop="fdDriverSalary" />
      <el-table-column label="司机提成" align="center" prop="fdDriverCommission" />
      <el-table-column label="司机社保" align="center" prop="fdDriverSocialSecurity" />
      <el-table-column label="伙食费标准" align="center" prop="fdMealStandard" />
      <el-table-column label="住宿费标准" align="center" prop="fdAccommodationStandard" />
      <el-table-column label="通信费标准" align="center" prop="fdCommunicationStandard" />
      <el-table-column label="罚款" align="center" prop="fdFine" />
      <el-table-column label="车公里成本合计" align="center" prop="fdTotalCostPerVehicleKilometer" />
      <el-table-column label="吨公里成本合计" align="center" prop="fdTotalCostPerTonneKilometer" />
      <el-table-column label="立方成本合计" align="center" prop="fdTotalCostPerCubicMeter" />
      <el-table-column label="备注" align="center" prop="fdRemark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ys:transportCostAccounting:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ys:transportCostAccounting:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改运输成本核算对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="序号" prop="fdSerialNum">
              <el-input v-model="form.fdSerialNum" placeholder="请输入序号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织名称" prop="fdOrganizationName">
              <el-input v-model="form.fdOrganizationName" placeholder="请输入组织名称" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织代码" prop="fdOrganizationCode">
              <el-input v-model="form.fdOrganizationCode" placeholder="请输入组织代码" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织层级" prop="fdOrganizationLevel">
              <el-input v-model="form.fdOrganizationLevel" placeholder="请输入组织层级" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车牌号码" prop="fdPlateNum">
              <el-input v-model="form.fdPlateNum" placeholder="请输入车牌号码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆条形码" prop="fdVehicleBarcode">
              <el-input v-model="form.fdVehicleBarcode" placeholder="请输入车辆条形码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预计车辆总运量" prop="fdEstimatedTotalVehicleVolume">
              <el-input v-model="form.fdEstimatedTotalVehicleVolume" placeholder="请输入预计车辆总运量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预计年总运量" prop="fdEstimatedAnnualTotalVehicleVolume">
              <el-input v-model="form.fdEstimatedAnnualTotalVehicleVolume" placeholder="请输入预计年总运量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车款总额" prop="fdTotalVehicleAmount">
              <el-input v-model="form.fdTotalVehicleAmount" placeholder="请输入车款总额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="折旧年限" prop="fdDepreciationYears">
              <el-input v-model="form.fdDepreciationYears" placeholder="请输入折旧年限" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="折旧月数" prop="fdDepreciationMonths">
              <el-input v-model="form.fdDepreciationMonths" placeholder="请输入折旧月数" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="折旧残值" prop="fdResidualValueOfDepreciation">
              <el-input v-model="form.fdResidualValueOfDepreciation" placeholder="请输入折旧残值" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公里折旧费小计" prop="fdSubtotalOfDepreciationPerKilometer">
              <el-input v-model="form.fdSubtotalOfDepreciationPerKilometer" placeholder="请输入公里折旧费小计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="贷款总额" prop="fdTotalLoanAmount">
              <el-input v-model="form.fdTotalLoanAmount" placeholder="请输入贷款总额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月贷" prop="fdMonthlyLoanPayment">
              <el-input v-model="form.fdMonthlyLoanPayment" placeholder="请输入月贷" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="利息总额" prop="fdTotalInterestPaid">
              <el-input v-model="form.fdTotalInterestPaid" placeholder="请输入利息总额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公里贷利费小计" prop="fdSubtotalOfLoanInterestAndFeesPerKilometer">
              <el-input v-model="form.fdSubtotalOfLoanInterestAndFeesPerKilometer" placeholder="请输入公里贷利费小计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保养费" prop="fdMaintenanceCost">
              <el-input v-model="form.fdMaintenanceCost" placeholder="请输入保养费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="维修费" prop="fdRepairCost">
              <el-input v-model="form.fdRepairCost" placeholder="请输入维修费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货运信息费" prop="fdCargoInformationFee">
              <el-input v-model="form.fdCargoInformationFee" placeholder="请输入货运信息费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车船使用费" prop="fdVehicleAndVesselUseFee">
              <el-input v-model="form.fdVehicleAndVesselUseFee" placeholder="请输入车船使用费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="交强险" prop="fdCompulsoryInsurance">
              <el-input v-model="form.fdCompulsoryInsurance" placeholder="请输入交强险" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商业险" prop="fdCommercialInsurance">
              <el-input v-model="form.fdCommercialInsurance" placeholder="请输入商业险" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年检费" prop="fdAnnualInspectionFee">
              <el-input v-model="form.fdAnnualInspectionFee" placeholder="请输入年检费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="营运费" prop="fdOperationalExpenses">
              <el-input v-model="form.fdOperationalExpenses" placeholder="请输入营运费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="耗费量" prop="fdFuelConsumption">
              <el-input v-model="form.fdFuelConsumption" placeholder="请输入耗费量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单价" prop="fdUnitPrice">
              <el-input v-model="form.fdUnitPrice" placeholder="请输入单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="燃料费用" prop="fdFuelCost">
              <el-input v-model="form.fdFuelCost" placeholder="请输入燃料费用" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="后处理费用" prop="fdPostProcessingCost">
              <el-input v-model="form.fdPostProcessingCost" placeholder="请输入后处理费用" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="过桥费" prop="fdBridgeToll">
              <el-input v-model="form.fdBridgeToll" placeholder="请输入过桥费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="过路费类别" prop="fdRoadTollCategory">
              <el-select v-model="form.fdRoadTollCategory" placeholder="请选择过路费类别">
                <el-option
                  v-for="dict in dict.type.toll_category"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="过路费" prop="fdRoadToll">
              <el-input v-model="form.fdRoadToll" placeholder="请输入过路费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="换轮胎里程" prop="fdMileageForTyreChange">
              <el-input v-model="form.fdMileageForTyreChange" placeholder="请输入换轮胎里程" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="轮胎单价" prop="fdUnitPriceOfTyre">
              <el-input v-model="form.fdUnitPriceOfTyre" placeholder="请输入轮胎单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="轮胎个数" prop="fdNumberOfTyres">
              <el-input v-model="form.fdNumberOfTyres" placeholder="请输入轮胎个数" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="轮胎单耗" prop="fdTireUnitConsumption">
              <el-input v-model="form.fdTireUnitConsumption" placeholder="请输入轮胎单耗" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机薪资" prop="fdDriverSalary">
              <el-input v-model="form.fdDriverSalary" placeholder="请输入司机薪资" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机提成" prop="fdDriverCommission">
              <el-input v-model="form.fdDriverCommission" placeholder="请输入司机提成" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机社保" prop="fdDriverSocialSecurity">
              <el-input v-model="form.fdDriverSocialSecurity" placeholder="请输入司机社保" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="伙食费标准" prop="fdMealStandard">
              <el-input v-model="form.fdMealStandard" placeholder="请输入伙食费标准" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="住宿费标准" prop="fdAccommodationStandard">
              <el-input v-model="form.fdAccommodationStandard" placeholder="请输入住宿费标准" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="通信费标准" prop="fdCommunicationStandard">
              <el-input v-model="form.fdCommunicationStandard" placeholder="请输入通信费标准" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="罚款" prop="fdFine">
              <el-input v-model="form.fdFine" placeholder="请输入罚款" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车公里成本合计" prop="fdTotalCostPerVehicleKilometer">
              <el-input v-model="form.fdTotalCostPerVehicleKilometer" placeholder="请输入车公里成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="吨公里成本合计" prop="fdTotalCostPerTonneKilometer">
              <el-input v-model="form.fdTotalCostPerTonneKilometer" placeholder="请输入吨公里成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="立方成本合计" prop="fdTotalCostPerCubicMeter">
              <el-input v-model="form.fdTotalCostPerCubicMeter" placeholder="请输入立方成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="fdRemark">
              <el-input v-model="form.fdRemark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <organizationalSelect ref="organizationalSelect" @onSelected="onSelected"></organizationalSelect>
  </div>
</template>

<script>
import { listTransportCostAccounting, getTransportCostAccounting, delTransportCostAccounting, addTransportCostAccounting, updateTransportCostAccounting } from "@/api/ys/transportCostAccounting";
import {getToken} from "@/utils/auth";
export default {
  name: "TransportCostAccounting",
  dicts: ['toll_category'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运输成本核算表格数据
      transportCostAccountingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fdOrganizationLevel: null,
        fdPlateNum: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`transportCostAccounting`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ys/transportCostAccounting/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询运输成本核算列表 */
    getList() {
      this.loading = true;
      listTransportCostAccounting(this.queryParams).then(response => {
        this.transportCostAccountingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        fdSerialNum: null,
        fdOrganizationName: null,
        fdOrganizationCode: null,
        fdOrganizationCategory: null,
        fdOrganizationLevel: null,
        fdPlateNum: null,
        fdVehicleBarcode: null,
        fdEstimatedTotalVehicleVolume: null,
        fdEstimatedAnnualTotalVehicleVolume: null,
        fdTotalVehicleAmount: null,
        fdDepreciationYears: null,
        fdDepreciationMonths: null,
        fdResidualValueOfDepreciation: null,
        fdSubtotalOfDepreciationPerKilometer: null,
        fdTotalLoanAmount: null,
        fdMonthlyLoanPayment: null,
        fdTotalInterestPaid: null,
        fdSubtotalOfLoanInterestAndFeesPerKilometer: null,
        fdMaintenanceCost: null,
        fdRepairCost: null,
        fdCargoInformationFee: null,
        fdVehicleAndVesselUseFee: null,
        fdCompulsoryInsurance: null,
        fdCommercialInsurance: null,
        fdAnnualInspectionFee: null,
        fdOperationalExpenses: null,
        fdFuelType: null,
        fdFuelConsumption: null,
        fdUnitPrice: null,
        fdFuelCost: null,
        fdPostProcessingCost: null,
        fdBridgeToll: null,
        fdRoadTollCategory: null,
        fdRoadToll: null,
        fdMileageForTyreChange: null,
        fdUnitPriceOfTyre: null,
        fdNumberOfTyres: null,
        fdTireUnitConsumption: null,
        fdDriverSalary: null,
        fdDriverCommission: null,
        fdDriverSocialSecurity: null,
        fdMealStandard: null,
        fdAccommodationStandard: null,
        fdCommunicationStandard: null,
        fdFine: null,
        fdTotalCostPerVehicleKilometer: null,
        fdTotalCostPerTonneKilometer: null,
        fdTotalCostPerCubicMeter: null,
        fdRemark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加运输成本核算";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTransportCostAccounting(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改运输成本核算";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTransportCostAccounting(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTransportCostAccounting(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delTransportCostAccounting(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('ys/transportCostAccounting/export', {
        ...this.queryParams
      }, `transportCostAccounting_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "运输成本核算导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('ys/transportCostAccounting/importTemplate', {
      }, `运输成本核算模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
